home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / FGL304B.ZIP;1 / MANUALS.ARJ / USER08.DOC < prev    next >
Encoding:
Text File  |  1994-01-24  |  52.2 KB  |  1,184 lines

  1. Chapter 8
  2.  
  3.  
  4.  
  5.  
  6.  
  7. Video Page Management
  8.  
  9. 150   Fastgraph User's Guide
  10.  
  11.  
  12. Overview
  13.  
  14.      The amount of memory required to store one full screen of information is
  15. called a video page.  This chapter will discuss video pages in detail, along
  16. with the Fastgraph routines you can use to manage video pages.
  17.  
  18.  
  19. Physical Pages and Virtual Pages
  20.  
  21.      Pages that use the memory that resides on the video adapter are called
  22. physical pages or true pages.  The number of physical pages available depends
  23. on the video mode and the amount of memory resident on the user's video
  24. adapter.  All video modes have at least one physical page.  In certain video
  25. modes, Fastgraph can allocate available random-access memory (RAM) and treat
  26. this memory as a video page.  Pages that use standard RAM in this sense are
  27. called virtual pages.  From a programmer's perspective, virtual pages are
  28. essentially identical to physical pages.
  29.  
  30.      The following table shows the number of physical pages in each video
  31. mode.  It also indicates whether or not specific video modes support virtual
  32. pages.
  33.  
  34.       Mode                                   Page Size Physical  Virtual
  35.      Number    Description                   in Bytes  Pages     Pages
  36.  
  37.         0      40 column color text            2,000        8    no
  38.         1      40 column color text            2,000        8    no
  39.         2      80 column color text            4,000        4    no
  40.         3      80 column color text            4,000        4    no
  41.         4      320x200x4 CGA graphics         16,000        1    yes
  42.         5      320x200x4 CGA graphics         16,000        1    yes
  43.         6      640x200x2 CGA graphics         16,000        1    yes
  44.         7      80 column monochrome text       4,000        1    yes
  45.         9      320x200x16 Tandy graphics      32,000        1    yes
  46.        11      720x348 Hercules graphics      31,320        2    yes
  47.        12      320x200 Hercules graphics      31,320        2    yes
  48.        13      320x200x16 EGA graphics        32,000        8    no
  49.        14      640x200x16 EGA graphics        64,000        4    no
  50.        15      640x350 EGA mono graphics      56,000        2    no
  51.        16      640x350x16 EGA graphics       112,000        2    no
  52.        17      640x480x2 MCGA/VGA graphics    38,400        1+   no
  53.        18      640x480x16 VGA graphics       153,600        1+   no
  54.        19      320x200x256 MCGA graphics      64,000        1    yes
  55.        20      320x200x256 XVGA graphics      64,000        4    no
  56.        21      320x400x256 XVGA graphics     128,000        2    no
  57.        22      320x240x256 XVGA graphics      76,800        3+   no
  58.        23      320x480x256 XVGA graphics     153,600        1+   no
  59.        24      640x400x256 SVGA graphics     256,000        4    no
  60.        25      640x480x256 SVGA graphics     307,200        2    no
  61.        26      800x600x256 SVGA graphics     480,000        2    no
  62.        27      1024x768x256 SVGA graphics    786,432        1+   no
  63.        28      800x600x16 SVGA graphics      240,000        4    no
  64.        29      1024x768x16 SVGA graphics     393,216        2    no
  65.  
  66. This table assumes the video adapter has 256K of video memory installed for
  67. EGA and VGA modes, and 1MB of video memory for SVGA modes.  For adapters with
  68.                                        Chapter 8:  Video Page Management   151
  69.  
  70.  
  71. less video memory, the number of physical pages is reduced proportionately.
  72. In other words, a 64K EGA has two video pages available instead of eight in
  73. mode 13.  Similarly, a 512K SVGA has one page instead of two in modes 25 and
  74. 26, and wouldn't support mode 27.  The next table summarizes the number of
  75. video pages available in SVGA graphics modes for video cards with 256K, 512K,
  76. 768K, and 1MB of video memory installed.
  77.  
  78.                 Mode                    Number of pages with...
  79.                Number    Resolution     256K 512K  768K 1MB
  80.  
  81.                  24      640x400x256     1+   2     3    4
  82.                  25      640x480x256     0    1+    1+   2
  83.                  26      800x600x256     0    1+    1+   2
  84.                  27      1024x768x256    0    0     1    1+
  85.                  28      800x600x16      1+   2     3    4
  86.                  29      1024x768x16     0    1+    1+   2
  87.  
  88.      In the preceding two tables, note that the number of physical pages in
  89. some video modes is followed by a plus symbol.  In these modes, there is an
  90. additional partial video page available.  For modes 17, 18, and 23, there is
  91. one full page (page 0) plus one partial page of 320 pixel rows (page 1).  For
  92. mode 22, there are three full physical pages (numbered 0 to 2) plus one
  93. partial page of 80 pixel rows (page 3).  For mode 27, there is one full page
  94. (page 0) plus one partial page of 256 pixel rows (page 1) on a 1MB SVGA card.
  95. You can safely use the partial pages as long as you don't reference pixel
  96. rows beyond its last available row.  However, you cannot make a partial video
  97. page the visual page.
  98.  
  99.      In SVGA graphics modes (modes 24 to 29), video pages must begin on 256K
  100. boundaries to maintain compatibility between different SVGA chipsets.  This
  101. results in unused video memory at the end of a page.  For example, pages in
  102. mode 26 require 480,000 bytes of video memory.  On a 1MB SVGA card, the two
  103. pages will begin at 0 and 524,288 (512K). Thus there are 44,288 (524,288
  104. minus 480,000) unused video memory bytes at the end of each page.  With 800
  105. pixels (and hence 800 bytes) per screen row, this means each page has an
  106. extra 55 pixel rows per page.  The actual page size is therefore 800 by 654,
  107. with the first 600 rows being displayed.
  108.  
  109.      Physical pages are numbered starting at zero.  For example, there are
  110. four physical video pages available in mode 3, and they are numbered 0 to 3.
  111. Virtual pages are numbered n to 63, where n is the number of physical pages
  112. in that mode.  For example, there are two physical pages (numbered 0 and 1)
  113. and 62 virtual pages (numbered 2 to 63) in mode 11.  Note only modes 4
  114. through 12 and mode 19 offer virtual pages, and the amount of conventional
  115. memory in the user's system usually limits the number of virtual pages
  116. available (this is especially true in mode 19 because of the large page
  117. size).
  118.  
  119.  
  120. Pages With Special Meanings
  121.  
  122.      There are three video pages that have special meanings to Fastgraph.
  123. The visual page, as one might guess, is the video page currently visible on
  124. the user's display.  The active page is the video page to which Fastgraph
  125. writes text or graphics information.  The hidden page is meaningful only to a
  126. few Fastgraph routines and will be discussed specifically within the context
  127. 152   Fastgraph User's Guide
  128.  
  129.  
  130. of those routines.  The fg_setmode routine sets all three of these pages to
  131. page 0, and it does not matter if these pages are physical or virtual.
  132.  
  133.      One of the most useful features of multiple video pages (either physical
  134. or virtual) is the ability to build a text or graphics image off screen (that
  135. is, on some video page besides the visual page).  Then, once the image is
  136. ready, we can either transfer it to the visual page, or make the page on
  137. which the image resides the visual page.  This feature is especially useful
  138. in animation, for it displays an image instantaneously instead of visibly
  139. updating the screen while producing the image.
  140.  
  141.  
  142. Some Simple Examples
  143.  
  144.      In this section, we will present six variations of a simple program that
  145. uses four video pages.  The program fills each video page with a rectangle
  146. and then displays text containing the video page number in the center of each
  147. page.  The first two examples run in a specific text or graphics video mode
  148. and only use physical pages.  The next two examples also run in a specific
  149. text or graphics video mode, but they also use virtual pages.  The final two
  150. examples are more general and run in several video modes.  You could of
  151. course write a program that essentially does the same thing as the examples
  152. in this section without using multiple video pages.  However, to use
  153. Fastgraph's image display and animation routines effectively, you must first
  154. understand the concept of video pages.
  155.  
  156.      Before proceeding, we must introduce the Fastgraph routines fg_setpage
  157. and fg_setvpage.  The fg_setpage routine defines the active video page, which
  158. causes Fastgraph to put subsequent text and graphics output on that page.
  159. The fg_setvpage routine defines the visual video page displayed on the
  160. screen.  Both routines take a single integer argument between 0 and 63 that
  161. specifies the video page number.  It does not matter if the referenced video
  162. page is a physical page or a virtual page.  As mentioned earlier, fg_setmode
  163. makes page 0 the active and visual video page.
  164.  
  165.      Example 8-1 uses four video pages (numbered 0 to 3) in the 40-column
  166. color text mode (mode 1).  The program first calls fg_testmode to check the
  167. availability of the requested video mode when used with four video pages.  If
  168. it is available, the program calls fg_setmode to establish that video mode.
  169. The first for loop fills each of the four pages with different color
  170. rectangles and then displays black text containing the video page number in
  171. the center of each page.  It does this by calling fg_setpage to define the
  172. active video page, fg_setcolor and fg_rect to draw the colored rectangles,
  173. and finally fg_setattr, fg_locate, and fg_text to display the text.  The
  174. program must call fg_locate inside the loop because each video page has its
  175. own text cursor position.  The second for loop successively makes each video
  176. page the visual page; the page remains displayed until you press a key.
  177. After displaying all four video pages, the program restores the original
  178. video mode and screen attributes before returning to DOS.
  179.  
  180.                                  Example 8-1.
  181.  
  182.                #include <fastgraf.h>
  183.                #include <stdio.h>
  184.                #include <stdlib.h>
  185.                void main(void);
  186.                                        Chapter 8:  Video Page Management   153
  187.  
  188.  
  189.                #define PAGES 4
  190.  
  191.                void main()
  192.                {
  193.                   int color;
  194.                   int old_mode;
  195.                   int page;
  196.                   char string[8];
  197.  
  198.                   if (fg_testmode(1,PAGES) == 0) {
  199.                      printf("This program requires color.\n");
  200.                      exit(1);
  201.                      }
  202.  
  203.                   old_mode = fg_getmode();
  204.                   fg_setmode(1);
  205.  
  206.                   for (page = 0; page < PAGES; page++) {
  207.                      fg_setpage(page);
  208.                      color = page + 1;
  209.                      fg_setcolor(color);
  210.                      fg_rect(0,fg_getmaxx(),0,fg_getmaxy());
  211.                      fg_setattr(0,color,0);
  212.                      fg_locate(12,17);
  213.                      sprintf(string,"page %d",page);
  214.                      fg_text(string,6);
  215.                      }
  216.  
  217.                   for (page = 0; page < PAGES; page++) {
  218.                      fg_setvpage(page);
  219.                      fg_waitkey();
  220.                      }
  221.  
  222.                   fg_setmode(old_mode);
  223.                   fg_reset();
  224.                }
  225.  
  226.      Example 8-2 is similar to example 8-1, but it uses the 320 by 200 EGA
  227. graphics mode (mode 13) instead of a text mode.  Note the only real
  228. difference between this program and the text mode version is the use of
  229. fg_setcolor instead of fg_setattr to make the text appear in black.
  230.  
  231.                                  Example 8-2.
  232.  
  233.                #include <fastgraf.h>
  234.                #include <stdio.h>
  235.                #include <stdlib.h>
  236.                void main(void);
  237.  
  238.                #define PAGES 4
  239.  
  240.                void main()
  241.                {
  242.                   int color;
  243.                   int old_mode;
  244.                   int page;
  245. 154   Fastgraph User's Guide
  246.  
  247.  
  248.                   char string[8];
  249.  
  250.                   if (fg_testmode(13,PAGES) == 0) {
  251.                      printf("This program requires a ");
  252.                      printf("320 x 200 EGA graphics mode.\n");
  253.                      exit(1);
  254.                      }
  255.  
  256.                   old_mode = fg_getmode();
  257.                   fg_setmode(13);
  258.  
  259.                   for (page = 0; page < PAGES; page++) {
  260.                      fg_setpage(page);
  261.                      color = page + 1;
  262.                      fg_setcolor(color);
  263.                      fg_rect(0,fg_getmaxx(),0,fg_getmaxy());
  264.                      fg_setcolor(0);
  265.                      fg_locate(12,17);
  266.                      sprintf(string,"page %d",page);
  267.                      fg_text(string,6);
  268.                      }
  269.  
  270.                   for (page = 0; page < PAGES; page++) {
  271.                      fg_setvpage(page);
  272.                      fg_waitkey();
  273.                      }
  274.  
  275.                   fg_setmode(old_mode);
  276.                   fg_reset();
  277.                }
  278.  
  279.  
  280.      Virtual video pages are created with Fastgraph's fg_allocate routine.
  281. The fg_allocate routine reserves conventional random-access memory (RAM)
  282. which Fastgraph then treats as a video page.  The amount of memory required
  283. depends on the current video mode.  The fg_allocate routine takes a single
  284. integer argument that specifies the page number by which the virtual page
  285. will be referenced.  This value must be between 0 and 63.
  286.  
  287.      If you try to create a virtual page with a page number already assigned
  288. to a physical page, fg_allocate does nothing.  For example, in the Hercules
  289. graphics modes (modes 11 and 12) there are two physical pages numbered 0 and
  290. 1.  Virtual pages in the Hercules graphics modes must thus have page numbers
  291. between 2 and 63.  If you tell fg_allocate to create a Hercules virtual page
  292. numbered 0 or 1, it does nothing because those video pages are physical
  293. pages.  Similarly, if you use the fg_allocate routine in a video mode that
  294. does not support virtual video pages, it simply returns without doing
  295. anything.
  296.  
  297.      A possible problem with fg_allocate can occur when there is not enough
  298. memory available for creating a virtual page in the current video mode.  The
  299. fg_allocate routine returns as its function value a status code indicating
  300. whether or not it was successful.  The possible values of the status code
  301. are:
  302.  
  303.         value  meaning
  304.                                        Chapter 8:  Video Page Management   155
  305.  
  306.           0    virtual page created
  307.           1    specified page number is a physical page
  308.           7    virtual page created, but memory control blocks were destroyed
  309.           8    insufficient memory to create the virtual page
  310.  
  311. If you use the fg_testmode or fg_bestmode routines to check if the required
  312. number of video pages are available when using the requested video mode, you
  313. should not need to monitor the status code returned by the fg_allocate
  314. routine.
  315.  
  316.      The fg_freepage routine releases the memory for a virtual page created
  317. with fg_allocate.  It requires a single integer argument that identifies the
  318. virtual page number to release.  This value must be between 0 and 63.  If you
  319. try to release a physical video page, or release a virtual page that was
  320. never created, fg_freepage does nothing.  It is a good idea to use
  321. fg_freepage to release all virtual video pages before a program returns
  322. control to DOS, or just before a program selects a new video mode.
  323.  
  324.      Example 8-3 is also similar to example 8-1, but it uses the monochrome
  325. text mode (mode 7).  Because the monochrome text mode only has one physical
  326. video page, we must use virtual video pages for page numbers 1, 2, and 3.
  327. Note how the fg_allocate and fg_freepage routines are used to create and
  328. release the virtual video pages in this example.
  329.  
  330.                                  Example 8-3.
  331.  
  332.              #include <fastgraf.h>
  333.              #include <stdio.h>
  334.              #include <stdlib.h>
  335.              void main(void);
  336.  
  337.              #define PAGES 4
  338.  
  339.              void main()
  340.              {
  341.                 int old_mode;
  342.                 int page;
  343.                 char string[8];
  344.  
  345.                 if (fg_testmode(7,PAGES) == 0) {
  346.                    printf("This program requires monochrome.\n");
  347.                    exit(1);
  348.                    }
  349.  
  350.                 old_mode = fg_getmode();
  351.                 fg_setmode(7);
  352.                 fg_cursor(0);
  353.  
  354.                 for (page = 0; page < PAGES; page++) {
  355.                    fg_allocate(page);
  356.                    fg_setpage(page);
  357.                    fg_setcolor(7);
  358.                    fg_rect(0,fg_getmaxx(),0,fg_getmaxy());
  359.                    fg_setattr(0,7,0);
  360.                    fg_locate(12,37);
  361.                    sprintf(string,"page %d",page);
  362.                    fg_text(string,6);
  363. 156   Fastgraph User's Guide
  364.  
  365.  
  366.                    }
  367.  
  368.                 for (page = 0; page < PAGES; page++) {
  369.                    fg_setvpage(page);
  370.                    fg_waitkey();
  371.                    fg_freepage(page);
  372.                    }
  373.  
  374.                 fg_setmode(old_mode);
  375.                 fg_reset();
  376.              }
  377.  
  378.      Example 8-4 is similar to example 8-3, but it uses the standard Hercules
  379. graphics mode (mode 11) instead of the monochrome text mode.  Because the
  380. Hercules graphics modes have two physical video pages, we must use virtual
  381. video pages for page numbers 2 and 3.  Note the only real difference between
  382. this program and the text mode version is the use of fg_setcolor instead of
  383. fg_setattr to make the text appear in black.
  384.  
  385.                                  Example 8-4.
  386.  
  387.                #include <fastgraf.h>
  388.                #include <stdio.h>
  389.                #include <stdlib.h>
  390.                void main(void);
  391.  
  392.                #define PAGES 4
  393.  
  394.                void main()
  395.                {
  396.                   int old_mode;
  397.                   int page;
  398.                   char string[8];
  399.  
  400.                   if (fg_testmode(11,PAGES) == 0) {
  401.                      printf("This program requires Hercules ");
  402.                      printf("monochrome graphics.\n");
  403.                      exit(1);
  404.                      }
  405.  
  406.                   old_mode = fg_getmode();
  407.                   fg_setmode(11);
  408.  
  409.                   for (page = 0; page < PAGES; page++) {
  410.                      fg_allocate(page);
  411.                      fg_setpage(page);
  412.                      fg_setcolor(7);
  413.                      fg_rect(0,fg_getmaxx(),0,fg_getmaxy());
  414.                      fg_setcolor(0);
  415.                      fg_locate(12,37);
  416.                      sprintf(string,"page %d",page);
  417.                      fg_text(string,6);
  418.                      }
  419.  
  420.                   for (page = 0; page < PAGES; page++) {
  421.                      fg_setvpage(page);
  422.                                        Chapter 8:  Video Page Management   157
  423.  
  424.  
  425.                      fg_waitkey();
  426.                      fg_freepage(page);
  427.                      }
  428.  
  429.                   fg_setmode(old_mode);
  430.                   fg_reset();
  431.                }
  432.  
  433.      Example 8-5 is a generalized version of examples 8-1 and 8-3 that runs
  434. in any 80-column text video mode.  To simplify the program, each video page
  435. is filled with rectangles of the same color.  Note that fg_allocate and
  436. fg_freepage are used to manage the virtual video pages in case fg_bestmode
  437. selects the monochrome text mode (mode 7).  If fg_bestmode selects one of the
  438. 80-column color text modes (which have four physical video pages),
  439. fg_allocate and fg_freepage will simply return without doing anything.
  440.  
  441.                                  Example 8-5.
  442.  
  443.                 #include <fastgraf.h>
  444.                 #include <stdio.h>
  445.                 #include <stdlib.h>
  446.                 void main(void);
  447.  
  448.                 #define PAGES 4
  449.  
  450.                 void main()
  451.                 {
  452.                    int old_mode, new_mode;
  453.                    int page;
  454.                    char string[8];
  455.  
  456.                    new_mode = fg_bestmode(80,25,PAGES);
  457.                    if (new_mode < 0) {
  458.                       printf("This program requires ");
  459.                       printf("an 80-column display.\n");
  460.                       exit(1);
  461.                       }
  462.  
  463.                    old_mode = fg_getmode();
  464.                    fg_setmode(new_mode);
  465.                    fg_cursor(0);
  466.  
  467.                    for (page = 0; page < PAGES; page++) {
  468.                       fg_allocate(page);
  469.                       fg_setpage(page);
  470.                       fg_setcolor(7);
  471.                       fg_rect(0,fg_getmaxx(),0,fg_getmaxy());
  472.                       fg_setattr(0,7,0);
  473.                       fg_locate(12,37);
  474.                       sprintf(string,"page %d",page);
  475.                       fg_text(string,6);
  476.                       }
  477.  
  478.                    for (page = 0; page < PAGES; page++) {
  479.                       fg_setvpage(page);
  480.                       fg_waitkey();
  481. 158   Fastgraph User's Guide
  482.  
  483.  
  484.                       fg_freepage(page);
  485.                       }
  486.  
  487.                    fg_setmode(old_mode);
  488.                    fg_reset();
  489.                 }
  490.  
  491.      Example 8-6 is a generalized version of examples 8-2 and 8-4 that runs
  492. in any 320 by 200 graphics video mode.  To simplify the program, each video
  493. page is filled with rectangles of the same color.  As in example 8-5,
  494. fg_allocate and fg_freepage are used to manage the virtual video pages in
  495. case fg_bestmode selects a video mode with fewer than four physical video
  496. pages.  Note the only real difference between this program and the text mode
  497. version is the use of fg_setcolor instead of fg_setattr to make the text
  498. appear in black.
  499.  
  500.                                  Example 8-6.
  501.  
  502.                 #include <fastgraf.h>
  503.                 #include <stdio.h>
  504.                 #include <stdlib.h>
  505.                 void main(void);
  506.  
  507.                 #define PAGES 4
  508.  
  509.                 void main()
  510.                 {
  511.                    int old_mode, new_mode;
  512.                    int page;
  513.                    char string[8];
  514.  
  515.                    new_mode = fg_bestmode(320,200,PAGES);
  516.                    if (new_mode < 0) {
  517.                       printf("This program requires a ");
  518.                       printf("320 x 200 graphics mode.\n");
  519.                       exit(1);
  520.                       }
  521.  
  522.                    old_mode = fg_getmode();
  523.                    fg_setmode(new_mode);
  524.  
  525.                    for (page = 0; page < PAGES; page++) {
  526.                       fg_allocate(page);
  527.                       fg_setpage(page);
  528.                       fg_setcolor(15);
  529.                       fg_rect(0,fg_getmaxx(),0,fg_getmaxy());
  530.                       fg_setcolor(0);
  531.                       fg_locate(12,17);
  532.                       sprintf(string,"page %d",page);
  533.                       fg_text(string,6);
  534.                       }
  535.  
  536.                    for (page = 0; page < PAGES; page++) {
  537.                       fg_setvpage(page);
  538.                       fg_waitkey();
  539.                       fg_freepage(page);
  540.                                        Chapter 8:  Video Page Management   159
  541.  
  542.  
  543.                       }
  544.  
  545.                    fg_setmode(old_mode);
  546.                    fg_reset();
  547.                 }
  548.  
  549.  
  550. Text Cursors
  551.  
  552.      As mentioned in the previous chapter, Fastgraph draws hardware
  553. characters at the position defined by the text cursor.  Like the graphics
  554. cursor, the text cursor is not a cursor in the true sense, but is simply a
  555. pair of character space (row,column) coordinates with a special meaning.  The
  556. first 8 video pages (that is, pages 0 through 7) each have their own text
  557. cursor.  Each subsequent group of 8 video pages (pages 8 through 15, pages 16
  558. to 23, and so forth) respectively share the same text cursor positions as the
  559. first 8 pages.  This means the fg_locate routine will update one of 8
  560. different text cursors depending on the active video page.  Similarly, the
  561. fg_where routine returns the text cursor position for the active page.  The
  562. fg_setmode routine sets all 8 text cursor positions to the character space
  563. coordinates (0,0).
  564.  
  565.      Example 8-7 demonstrates the use of different text cursors in an 80-
  566. column color text mode (mode 3).  The program first displays the text "Page "
  567. on video page 0 (the visible page) and waits for a keystroke.  It then makes
  568. page 1 the active video page, changes the text cursor location for that page,
  569. and displays the text "Page 1" on video page 1.  Next, it appends the
  570. character "0" to the text originally displayed on page 0.  Note it is not
  571. necessary to restore the text cursor position for page 0 because it is
  572. unaffected by changing the text cursor for page 1.  After waiting for another
  573. keystroke, the program makes video page 1 the visual page and then waits for
  574. yet another keystroke before returning to DOS.
  575.  
  576.                                  Example 8-7.
  577.  
  578.                          #include <fastgraf.h>
  579.                          void main(void);
  580.  
  581.                          void main()
  582.                          {
  583.                             int old_mode;
  584.  
  585.                             old_mode = fg_getmode();
  586.                             fg_setmode(3);
  587.                             fg_cursor(0);
  588.                             fg_setattr(10,0,0);
  589.  
  590.                             fg_locate(1,0);
  591.                             fg_text("Page ",5);
  592.                             fg_waitkey();
  593.  
  594.                             fg_setpage(1);
  595.                             fg_locate(23,0);
  596.                             fg_text("Page 1",6);
  597.  
  598.                             fg_setpage(0);
  599. 160   Fastgraph User's Guide
  600.  
  601.  
  602.                             fg_text("0",1);
  603.                             fg_waitkey();
  604.  
  605.                             fg_setvpage(1);
  606.                             fg_waitkey();
  607.  
  608.                             fg_setmode(old_mode);
  609.                             fg_reset();
  610.                          }
  611.  
  612.  
  613. Obtaining Video Page Information
  614.  
  615.      Fastgraph includes two routines, fg_getpage and fg_getvpage, that
  616. respectively return the current active or visual video page number.  Each
  617. routine returns the video page number as its function value, and neither
  618. routine requires any arguments.
  619.  
  620.      The fg_getaddr routine is sometimes useful when using virtual pages.  It
  621. returns as its function value the segment address for the start of the active
  622. video page.  It does not require any arguments.  Although fg_getaddr is more
  623. useful when using virtual video pages, it works equally well when using
  624. physical video pages.
  625.  
  626.      Example 8-8 illustrates the use of the fg_getpage, fg_getvpage, and
  627. fg_getaddr routines in the standard CGA color graphics mode (mode 4).  This
  628. video mode offers only one physical page, so the program uses fg_allocate to
  629. create a virtual video page (page 1).  After creating the virtual page, the
  630. program makes it the active video page; page 0 remains the visual video page.
  631. The fg_getpage routine then returns the active page number (1), followed by a
  632. call to fg_getvpage to return the visual page number (0).  Next, the program
  633. uses fg_getaddr to return the segment address for video pages 0 and 1.
  634. Finally, it restores the original video mode and screen attributes, displays
  635. the returned values, and returns to DOS.
  636.  
  637.                                  Example 8-8.
  638.  
  639.                  #include <fastgraf.h>
  640.                  #include <stdio.h>
  641.                  void main(void);
  642.  
  643.                  void main()
  644.                  {
  645.                     int old_mode;
  646.                     int active, visual;
  647.                     int page0, page1;
  648.  
  649.                     old_mode = fg_getmode();
  650.                     fg_setmode(4);
  651.                     fg_allocate(1);
  652.                     fg_setpage(1);
  653.  
  654.                     active = fg_getpage();
  655.                     visual = fg_getvpage();
  656.  
  657.                     fg_setpage(0);
  658.                                        Chapter 8:  Video Page Management   161
  659.  
  660.  
  661.                     page0 = fg_getaddr();
  662.                     fg_setpage(1);
  663.                     page1 = fg_getaddr();
  664.  
  665.                     fg_freepage(1);
  666.                     fg_setmode(old_mode);
  667.                     fg_reset();
  668.  
  669.                     printf("Active page is %d.\n",active);
  670.                     printf("Visual page is %d.\n",visual);
  671.                     printf("Page 0 address is %4X\n",page0);
  672.                     printf("Page 1 address is %4X\n",page1);
  673.                  }
  674.  
  675.  
  676. Considerations for Virtual Pages
  677.  
  678.      If you're using Power C, QuickBASIC, Visual Basic, Borland Pascal, or
  679. Turbo Pascal and need to create virtual pages, you must reduce the size of
  680. the far heap.  Normally, these compilers allocate all remaining memory for
  681. the heap, which means fg_allocate will not be able to allocate memory for the
  682. virtual page.
  683.      In QuickBASIC and Visual Basic programs, the SETMEM function reduces the
  684. size of the far heap.  The BASIC versions of the Fastgraph example programs
  685. include the statement
  686.  
  687.                           SetMemStatus& = SETMEM(-n)
  688.  
  689. before calling FGallocate.  This reduces the size of the far heap by n bytes.
  690. For a given video mode, the actual reduction needed is the number of virtual
  691. pages multiplied by the page size in that mode.  Page sizes are listed at the
  692. beginning of this chapter, or you can use fg_pagesize to determine the page
  693. size for the current video mode.
  694.  
  695.      In Borland Pascal and Turbo Pascal, the $M compiler directive defines
  696. the maximum heap size in bytes.  The Pascal versions of the Fastgraph example
  697. programs include the statement
  698.  
  699.                               {$M 16384,0,16384}
  700.  
  701. at the beginning of the examples that call fg_allocate.  The third value in
  702. this list defines the maximum heap size at 16K bytes.  This is suitable for
  703. most applications, but if your program uses the New or GetMem procedures to
  704. create dynamic variables that require more heap space, you'll need to
  705. increase the size beyond 16K.
  706.  
  707.      The far heap size for Power C programs is defined at link time.  You
  708. must override the default heap size by including the option [,,16K] on the
  709. PCL command when you link a Power C program that uses fg_allocate.  The value
  710. 16K is suitable for most applications, but if your program calls the
  711. farcalloc or farmalloc functions (or the calloc or malloc functions when
  712. using the large memory model), you may need to increase the far heap size
  713. beyond 16K.
  714.  
  715.      When you are using virtual pages, you should avoid using the fg_setvpage
  716. routine in sections of the program that require fast screen updates or
  717. 162   Fastgraph User's Guide
  718.  
  719. animation sequences.  This is because the PC and PS/2 video BIOS are only
  720. capable of displaying physical pages.  To compensate for this restriction,
  721. Fastgraph exchanges the contents of a physical page with the requested
  722. virtual page.  In other words, if page 1 is a virtual page and you make it
  723. the visual page, Fastgraph will exchange the contents of page 1 with whatever
  724. page was previously the visual page.  This does not mean Fastgraph's page
  725. numbers change because Fastgraph also maintains an internal table containing
  726. video page addresses and exchanges the two corresponding table entries.  As
  727. before, you would make page 1 the active video page if you wanted to write
  728. something to the visual page.
  729.  
  730.      About the only other potential problem when using virtual pages is what
  731. happens when you try to write to a non-existent video page (for example, if
  732. you write to virtual video page 1 before creating it with fg_allocate).  In
  733. this case, Fastgraph simply redirects the video output to the visual page.
  734.  
  735.  
  736. Logical Pages
  737.  
  738.      In addition to physical and virtual video pages, Fastgraph offers
  739. another class of video pages, called logical pages.  You can create logical
  740. pages in any video mode.  They can exist in conventional memory, expanded
  741. memory (EMS), or extended memory (XMS).  However, they are not as versatile
  742. as physical or virtual pages because the only operations you can perform with
  743. logical pages are:
  744.  
  745.        Copy an entire physical or virtual page to a logical page
  746.        Copy an entire logical page to a physical or virtual page
  747.        Copy an entire logical page to another logical page
  748.  
  749. Three Fastgraph routines -- fg_alloccms, fg_allocems, and fg_allocxms --
  750. create logical pages in conventional memory, expanded memory, and extended
  751. memory, respectively.  All three routines have a single integer argument that
  752. specifies the page number by which the logical page will be referenced.  The
  753. page number must be between 1 and 63 and must not reference a physical or
  754. virtual page.  Their return value is 0 if the logical page is created, and
  755. negative otherwise (refer to the descriptions of these routines in the
  756. Fastgraph Reference Manual for a complete list of return values).  As with
  757. virtual pages, use the fg_freepage function to release a logical page.
  758.  
  759.      Before you can create logical pages in expanded or extended memory, you
  760. must initialize these resources for use with Fastgraph.  The fg_initems
  761. routine initializes expanded memory.  To use expanded memory, you must have
  762. an Expanded Memory Manager (EMM) that conforms to the Lotus/Intel/Microsoft
  763. Expanded Memory Specification (LIM-EMS) version 3.2 or later.  On 80386 and
  764. 80486 systems, the EMM386.EXE device driver supplied with DOS 5.0 can be used
  765. to treat some or all of extended memory as expanded memory.  The fg_initxms
  766. routine initializes extended memory for use with Fastgraph.  To use extended
  767. memory, you must have an XMS driver that conforms to the
  768. Lotus/Intel/Microsoft/AST eXtended Memory Specification version 2.0 or later,
  769. such as HIMEM.SYS.  XMS drivers require an 80286, 80386, or 80486 system.
  770. The fg_initems and fg_initxms routines have no arguments.  Their return value
  771. is 0 if successful, and -1 if the required driver and resources are not
  772. present.
  773.  
  774.      Example 8-9 illustrates the use of logical pages in a 320 by 200 color
  775. graphics mode.  The program first tries to create a logical page in extended
  776.                                        Chapter 8:  Video Page Management   163
  777.  
  778. memory by calling fg_initxms and fg_allocxms.  If the initialization or page
  779. creation fails, it then tries to create the page in expanded memory with
  780. fg_initems and fg_allocems.  Should that fail, the program calls fg_alloccms
  781. to try to create the page in conventional memory.  If it can't create the
  782. logical page at all, the program displays an error message and exits.
  783.  
  784.      Once the logical page is created, example 8-9 displays the word "test"
  785. in the middle of the visual page (page 0) and then uses fg_copypage to
  786. transfer the visual page contents to the logical page (page 8).  Because this
  787. program runs in one of several different graphics modes, we must use a
  788. logical page number greater than any possible physical page number.  We chose
  789. page 8 because mode 13 has physical pages numbered 0 through 7, and no mode
  790. has higher-numbered physical pages.  After waiting for a keystroke, the
  791. program erases the visual page, waits for another keystroke, and copies the
  792. logical page contents back to the visual page.  It then releases the logical
  793. page and exits.
  794.  
  795.                                  Example 8-9.
  796.  
  797.               #include <fastgraf.h>
  798.               #include <stdio.h>
  799.               #include <stdlib.h>
  800.               void main(void);
  801.  
  802.               void main()
  803.               {
  804.                  int new_mode, old_mode;
  805.                  int status;
  806.  
  807.                  new_mode = fg_bestmode(320,200,1);
  808.                  if (new_mode < 0 || new_mode == 12) {
  809.                     printf("This program requires a 320 ");
  810.                     printf("x 200 color graphics mode.\n");
  811.                     exit(1);
  812.                     }
  813.                  old_mode = fg_getmode();
  814.                  fg_setmode(new_mode);
  815.  
  816.                  status = fg_initxms();
  817.                  if (status == 0) status = fg_allocxms(8);
  818.                  if (status < 0) {
  819.                     status = fg_initems();
  820.                     if (status == 0) status = fg_allocems(8);
  821.                     }
  822.                  if (status < 0) status = fg_alloccms(8);
  823.  
  824.                  if (status < 0) {
  825.                     fg_setmode(old_mode);
  826.                     fg_reset();
  827.                     printf("Unable to create logical page.\n");
  828.                     exit(1);
  829.                     }
  830.  
  831.                  fg_setcolor(7);
  832.                  fg_rect(0,319,0,199);
  833.                  fg_setcolor(9);
  834.                  fg_locate(12,18);
  835. 164   Fastgraph User's Guide
  836.  
  837.  
  838.                  fg_text("test",4);
  839.                  fg_waitkey();
  840.  
  841.                  fg_copypage(0,8);
  842.                  fg_erase();
  843.                  fg_waitkey();
  844.  
  845.                  fg_copypage(8,0);
  846.                  fg_waitkey();
  847.  
  848.                  fg_freepage(8);
  849.                  fg_setmode(old_mode);
  850.                  fg_reset();
  851.               }
  852.  
  853.      As mentioned before, the only function you can perform with logical
  854. pages is copying one video page to another.  The fg_copypage routine provides
  855. the only way to do this for logical pages.  See Chapter 11 for more
  856. information about fg_copypage.
  857.  
  858.  
  859. Video Page Resizing
  860.  
  861.      Resizing is the process of changing the dimensions of a video page.  It
  862. is available only in the native EGA graphics modes (modes 13 to 16), native
  863. VGA graphics modes (17 and 18), extended VGA modes (20 to 23), and SVGA modes
  864. (24 to 29).  Resizing does not change the screen resolution, but instead
  865. increases the video page size so that only part of the page is visible.  For
  866. now, we'll just introduce resizing with a simple example, but in Chapter 13
  867. we'll see its real power when we perform smooth panning.
  868.  
  869.      The Fastgraph routine fg_resize changes the dimensions of a video page.
  870. Its two integer arguments define the page width and page height, both in
  871. pixels.  Example 8-10 runs in the 320 by 200 EGA graphics mode (mode 13).
  872. After establishing the video mode, it displays the word "resize" starting in
  873. column 38 of row 0.  Because the characters extend beyond the last column of
  874. the row, they wrap to the next row.  The program continues displaying this
  875. until you press a key.  Then, it clears the screen and calls fg_resize to
  876. make the page size 640 by 200 pixels.  Again the program displays the word
  877. "resize" starting in column 38 of row 0, but this time it does not wrap to
  878. the next row.  This is because the resizing doubled the page width, which
  879. increased the number of character cells per row from 40 to 80.  The
  880. characters that formerly wrapped to the next row now continue on an off-
  881. screen portion of the same row.
  882.  
  883.                                 Example 8-10.
  884.  
  885.                 #include <fastgraf.h>
  886.                 #include <stdio.h>
  887.                 #include <stdlib.h>
  888.                 void main(void);
  889.  
  890.                 void main()
  891.                 {
  892.                    int old_mode;
  893.  
  894.                                        Chapter 8:  Video Page Management   165
  895.  
  896.  
  897.                    if (fg_testmode(13,1) == 0) {
  898.                       printf("This program requires a 320 ");
  899.                       printf("x 200 EGA graphics mode.\n");
  900.                       exit(1);
  901.                       }
  902.  
  903.                    old_mode = fg_getmode();
  904.                    fg_setmode(13);
  905.  
  906.                    fg_setcolor(9);
  907.                    fg_locate(0,38);
  908.                    fg_text("resize",6);
  909.                    fg_waitkey();
  910.  
  911.                    fg_erase();
  912.                    fg_resize(640,200);
  913.                    fg_setcolor(10);
  914.                    fg_locate(0,38);
  915.                    fg_text("resize",6);
  916.                    fg_waitkey();
  917.  
  918.                    fg_setmode(old_mode);
  919.                    fg_reset();
  920.                 }
  921.  
  922.  
  923.      The size of a video page is constrained only by the amount of video
  924. memory available.  Increasing the video page size reduces the number of
  925. physical pages available proportionally.  In mode 13, for example, increasing
  926. the page size from 320 by 200 to 640 by 400 reduces the number of video pages
  927. from 8 to 2.  When you call fg_resize, the visual page must be page 0.  If
  928. you have created any logical video pages, you must release them with
  929. fg_freepage before calling fg_resize, and then create them again afterward.
  930. If you have initialized the mouse (with fg_mouseini), joysticks (with
  931. fg_initjoy), expanded memory (with fg_initems), or extended memory (with
  932. fg_initxms), you should re-initialize these resources after calling
  933. fg_resize.  Most mouse drivers expect a fixed video page width, so the mouse
  934. cursor may become distorted after resizing video pages.  When you call
  935. fg_resize, Fastgraph sets the clipping region to the new page limits.  The
  936. fg_setmode routine re-establishes the dimensions of a video page to the
  937. default screen resolution for the selected video mode.
  938.  
  939.       Depending on the dimensions passed to fg_resize, you may end up with a
  940. partial video page.  Again, suppose we're using mode 13 and have changed the
  941. page size to 960 by 400 (this is six times the default page size).  The
  942. original pages 0 to 5 now comprise page 0, and original pages 6 and 7 now
  943. comprise page 1.  However, there is not enough video memory left on page 1
  944. for a full 960 by 400 page.  In this case, the number of pixel rows available
  945. on page 1 would be one-third the full page size, or 133 rows.  This is
  946. because the total storage required by original pages 6 and 7 is one-third the
  947. total required for original pages 0 through 5.
  948. 166   Fastgraph User's Guide
  949.  
  950.  
  951.  
  952. Preserving Video Page Contents Across Mode Switches
  953.  
  954.      Sometimes a graphics program may temporarily need to switch to another
  955. video mode.  An example of this might be a graphical user interface (GUI)
  956. menuing system that includes "shell to DOS" as one of its options.  When the
  957. user selects this option, the program must revert to a text video mode so the
  958. user will see the familiar DOS prompt when the shell executes.  On leaving
  959. the DOS shell, the program returns to a graphics mode and should ideally
  960. restore the screen to what it was originally.
  961.  
  962.      When you establish a video mode with fg_setmode, Fastgraph clears all
  963. physical video pages and initializes its internal page tables as if no
  964. virtual or logical pages have been created.  While it's not possible to
  965. preserve physical page contents across video mode switches, you can use
  966. Fastgraph's fg_getentry and fg_setentry routines to save virtual or logical
  967. page contents.  The trick, so to speak, is using fg_getentry to save the
  968. virtual or logical page address and type before switching video modes.  Then,
  969. when you return to the same video mode, you can use fg_setentry to restore
  970. the internal page tables to their previous state.  This effectively makes the
  971. virtual or logical page accessible again.
  972.  
  973.      Example 8-11 illustrates this process.  This program runs in video mode
  974. 18, the 640 by 480 16-color VGA graphics mode.  After establishing this video
  975. mode, the program calls fg_alloccms to create a logical page in conventional
  976. memory (we chose page 2 because this is the first page number available for
  977. logical pages in mode 18).  Next, it calls fg_getentry to save the address
  978. and type of the logical page just created.  The first argument to fg_getentry
  979. specifies the page number; the next two arguments receive the page address
  980. and type.  Page type codes used by fg_getentry and fg_setentry are as
  981. follows:
  982.  
  983.      0 = unallocated page
  984.      1 = physical page
  985.      2 = virtual page
  986.      3 = logical page in expanded memory (EMS)
  987.      4 = logical page in extended memory (XMS)
  988.      5 = logical page in conventional memory
  989.  
  990.      After this setup work, example 8-11 fills the screen with light blue
  991. pixels, draws a white box around the edge, and then waits for a keystroke.
  992. Before switching back to the original video mode (assumed to be mode 3), the
  993. program uses fg_copypage to copy the visual page contents to the logical
  994. page.  This is necessary because we can only save virtual or logical page
  995. contents across video mode changes, not physical pages.  In mode 3, the
  996. program prompts for a keystroke before returning to mode 18.
  997.  
  998.      Now we're ready to restore the previous contents of the visual page.
  999. Because the example program did not release the logical page, the memory is
  1000. still allocated; Fastgraph just cannot access it.  To solve this, the program
  1001. calls fg_setentry to restore Fastgraph's internal page table entries for page
  1002. 2 to what they were previously.  Note how we use the same page address and
  1003. type values in the call to fg_setentry that were returned earlier by
  1004. fg_getentry.  Now that the logical page (page 2) is once again accessible,
  1005. the program can use fg_copypage to copy its contents back to the visual page.
  1006. With that explanation behind us, here is example 8-11.
  1007.                                        Chapter 8:  Video Page Management   167
  1008.  
  1009.  
  1010.                                 Example 8-11.
  1011.  
  1012.                    #include <fastgraf.h>
  1013.                    void main(void);
  1014.  
  1015.                    void main()
  1016.                    {
  1017.                       int old_mode;
  1018.                       int page_addr, page_type;
  1019.  
  1020.                       old_mode = fg_getmode();
  1021.                       fg_setmode(18);
  1022.                       fg_alloccms(2);
  1023.                       fg_getentry(2,&page_addr,&page_type);
  1024.  
  1025.                       fg_setcolor(9);
  1026.                       fg_fillpage();
  1027.                       fg_setcolor(15);
  1028.                       fg_box(0,639,0,479);
  1029.                       fg_waitkey();
  1030.  
  1031.                       fg_copypage(0,2);
  1032.                       fg_setmode(old_mode);
  1033.                       fg_cursor(0);
  1034.                       fg_setcolor(15);
  1035.                       fg_text("Press any key.",14);
  1036.                       fg_waitkey();
  1037.  
  1038.                       fg_setmode(18);
  1039.                       fg_setentry(2,page_addr,page_type);
  1040.                       fg_copypage(2,0);
  1041.                       fg_waitkey();
  1042.  
  1043.                       fg_freepage(2);
  1044.                       fg_setmode(old_mode);
  1045.                       fg_reset();
  1046.                    }
  1047.  
  1048.  
  1049.      To keep the example as simple as possible, it does not test for
  1050. availability of video modes, nor does it check if the logical page creation
  1051. was successful.  In a real application, of course, omitting these checks is
  1052. not recommended.
  1053.  
  1054.  
  1055. Controlling Page Allocation
  1056.  
  1057.      When Fastgraph creates virtual or logical pages in conventional memory
  1058. with fg_allocate or fg_alloccms, it uses the DOS allocate memory service
  1059. (function 48 hex of interrupt 21 hex).  Some compilers allocate all or part
  1060. of available conventional memory to a data structure called the heap or far
  1061. heap.  Memory allocation functions such as malloc handle their requests
  1062. through an associated heap manager instead of through DOS services.  If the
  1063. heap manager controls all available memory, the DOS allocate memory service
  1064. is essentially disabled because there will be no memory available to satisfy
  1065. allocation requests.  If the heap manager controls some but not all available
  1066. 168   Fastgraph User's Guide
  1067.  
  1068. memory, a conflict may arise between the heap manager and the DOS allocate
  1069. memory service.
  1070.  
  1071.      To solve this problem, you can use the compiler's allocate far memory
  1072. function to reserve memory for the virtual or logical page and then make the
  1073. page known to Fastgraph with fg_setentry.  The easiest way to determine the
  1074. amount of memory to allocate is through the fg_pagesize function, which
  1075. returns the page size in bytes (as a long integer) for the current video
  1076. mode.  To release the page, use fg_setentry with a page type of zero to mark
  1077. the page as unallocated before actually freeing the memory.  Pages created
  1078. this way are not initially cleared because the allocated memory block
  1079. contents are undefined.  We recommend using fg_erase to set the page contents
  1080. to the background color.
  1081.  
  1082.      Example 8-12 shows how to create a virtual page using these techniques
  1083. instead of fg_allocate.  It uses the farmalloc and farfree functions from the
  1084. C run-time library for Borland compilers (the analogous Microsoft functions
  1085. are _fmalloc and _ffree).  Example 8-12 uses fg_pagesize and the Borland run-
  1086. time library function farmalloc to create a virtual page in the 320 by 200
  1087. VGA/MCGA 256-color graphics mode.  After allocating the memory, the program
  1088. calls fg_setentry, passing it the page number (1), the segment portion of the
  1089. memory block address (using the FP_SEG macro from the run-time library), and
  1090. the code for a virtual page (2).  Once the virtual page is set up, the
  1091. program writes some text on the virtual page and then uses fg_copypage to
  1092. display the virtual page contents on the visual page.  Finally, it releases
  1093. the page by calling fg_setentry (so Fastgraph knows the virtual page is gone)
  1094. and the farfree run-time library function (to actually free the memory).  The
  1095. call to fg_setentry is not really needed in this instance because no further
  1096. references are made to page 1.
  1097.  
  1098.                                 Example 8-12.
  1099.  
  1100.            #include <fastgraf.h>
  1101.            #include <dos.h>
  1102.            #ifdef __TURBOC__
  1103.            #include <alloc.h>
  1104.            #else
  1105.            #include <malloc.h>
  1106.            #define  farfree(p)   _ffree(p)
  1107.            #define  farmalloc(n) _fmalloc(n)
  1108.            #endif
  1109.            void main(void);
  1110.  
  1111.            void main()
  1112.            {
  1113.               int old_mode;
  1114.               unsigned page_addr;
  1115.               char far *buffer;
  1116.  
  1117.               old_mode = fg_getmode();
  1118.               fg_setmode(19);
  1119.               buffer = farmalloc(fg_pagesize()+16);
  1120.               page_addr = FP_SEG(buffer) + (FP_OFF(buffer)+15)/16;
  1121.               fg_setentry(1,page_addr,2);
  1122.  
  1123.               fg_setpage(1);
  1124.               fg_erase();
  1125.                                        Chapter 8:  Video Page Management   169
  1126.  
  1127.  
  1128.               fg_setcolor(9);
  1129.               fg_text("This is page 1.",15);
  1130.               fg_waitkey();
  1131.  
  1132.               fg_copypage(1,0);
  1133.               fg_setentry(1,0,0);
  1134.               fg_waitkey();
  1135.  
  1136.               farfree(buffer);
  1137.               fg_setmode(old_mode);
  1138.               fg_reset();
  1139.            }
  1140.  
  1141.  
  1142.  
  1143. Summary of Video Page Management Routines
  1144.  
  1145.      This section summarizes the functional descriptions of the Fastgraph
  1146. routines presented in this chapter.  More detailed information about these
  1147. routines, including their arguments and return values, may be found in the
  1148. Fastgraph Reference Manual.
  1149.  
  1150.      FG_ALLOCATE creates a virtual video page.  The amount of memory required
  1151. depends on the current video mode.  This routine has no effect if it
  1152. references a physical or logical video page.
  1153.  
  1154.      FG_ALLOCEMS creates a logical page in expanded memory (EMS).  The amount
  1155. of memory required depends on the current video mode and video buffer
  1156. dimensions.  This routine has no effect if it references a physical or
  1157. virtual video page.
  1158.  
  1159.      FG_ALLOCXMS creates a logical page in extended memory (XMS).  The amount
  1160. of memory required depends on the current video mode and video buffer
  1161. dimensions.  This routine has no effect if it references a physical or
  1162. virtual video page.
  1163.  
  1164.      FG_COPYPAGE transfers the contents of one video page to another.  The
  1165. pages may be physical, virtual, or logical video pages.  If both pages are
  1166. logical pages, they must exist in the same type of memory.
  1167.  
  1168.      FG_FREEPAGE releases a virtual or logical video page created with the
  1169. fg_allocate, fg_alloccms, fg_allocems, or fg_allocxms routines.  This routine
  1170. has no effect if it references a physical video page, or a virtual page that
  1171. was never created.
  1172.  
  1173.      FG_GETADDR returns the segment address of the active video page.
  1174.  
  1175.      FG_GETENTRY retrieves the type and address of a physical, virtual, or
  1176. logical video page.  This routine is useful for saving virtual or logical
  1177. page contents across video mode changes.
  1178.  
  1179.      FG_GETPAGE returns the active video page number.
  1180.  
  1181.      FG_GETVPAGE returns the visual video page number.
  1182.  
  1183.      FG_INITEMS initializes expanded memory for use with Fastgraph.
  1184. 170   Fastgraph User's Guide
  1185.  
  1186.  
  1187.      FG_INITXMS initializes extended memory for use with Fastgraph.
  1188.  
  1189.      FG_PAGESIZE returns the video page size in bytes for the current video
  1190. mode.
  1191.  
  1192.      FG_RESIZE changes the dimensions of a video page in EGA and VGA graphics
  1193. modes.
  1194.  
  1195.      FG_SETENTRY specifies the type and address of a physical, virtual, or
  1196. logical video page.  For logical pages, it further specifies if the page
  1197. resides in conventional, expanded, or extended memory.  This routine is
  1198. useful for saving virtual or logical page contents across video mode changes,
  1199. or for manual creation of virtual and logical pages.
  1200.  
  1201.      FG_SETPAGE establishes the active video page.  It may be a physical or
  1202. virtual page.
  1203.  
  1204.      FG_SETVPAGE establishes the visual video page.  It may be a physical or
  1205. virtual page.
  1206.